(function(e) {
	e('.mui-scroll-wrapper').scroll({
		indicators: true //是否显示滚动条
	});
	var map = new AMap.Map("container", {
		resizeEnable: true,
		center: centerPoint, //地图中心点
		zoom: 15 //地图显示的缩放级别
	});
	Geolocation(map);
})(mui);

function Geolocation(map) {
	map.plugin('AMap.Geolocation', function() {
		geolocation = new AMap.Geolocation({
			enableHighAccuracy: true, //是否使用高精度定位，默认:true
			timeout: 10000, //超过10秒后停止定位，默认：无穷大
			buttonOffset: new AMap.Pixel(10, 20), //定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
			zoomToAccuracy: false, //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
			buttonPosition: 'RB'
		});
		map.addControl(geolocation);
		geolocation.getCurrentPosition();
		AMap.event.addListener(geolocation, 'complete', function(data) {
			AMap.service(["AMap.PlaceSearch"], function() {
				var placeSearch = new AMap.PlaceSearch({ //构造地点查询类
					pageSize: 30,
					type: '公交车站|地铁',
					pageIndex: 1,
					city: city, //城市
					extensions: 'all',
					map: map
				});

				var cpoint = data.position; //中心点坐标
				placeSearch.searchNearBy('', cpoint, 800, function(status, result) {
					if(status == 'complete') {
						console.log(JSON.stringify(result));
						
						var poiList = result.poiList;
						
						if(isEmpty(poiList) || isEmpty(poiList.pois) || poiList.pois.length == 0){
							$("#panel").html('<p class="null-list-div">暂无站点信息</p>');
							$("#panel").hide();
							$("#container").css('width' , '100%');
							return;
						}
						
						
						var pois = poiList.pois;
						removeLi("poiList");
						for (var i = 0; i < pois.length; i++) {
							createItem(pois[i]);
						}
						
						
					} else {
						mui.toast("获取站点失败！");
					}
				});
			});
			console.log("定位成功")
		});
		AMap.event.addListener(geolocation, 'error', function(e) {
			console.log("error" + e.message);
		});
	});
}

function createItem(row){
	var html = '<li id="'+ row.name +'" class="mui-table-view-cell open-url" data-url="bus_info.html?id='+row.name+'&address='+ row.address +'" >';
	html +=  '<h5>站点名称：'+ row.name +'</h5><span>距离我'+ row.distance +'米</span><p>站点信息：'+ row.address +'</p></li>'
	$(".poi-list").append(html);
	
}
